package test_pkg

import (
	"fmt"
	"log"
	"net/http"
)

// curl http://localhost:5000/tt?name=11
func http_server(w http.ResponseWriter, req *http.Request) {
	fmt.Println("Inside httpServer handler")
	//post 请求用 req.FormValue("var1") 获取参数
	fmt.Printf("req.URL.Path[1:]: %v\n", req.URL.Path[1:]) // Hello,tt
	fmt.Fprintf(w, "Hello,"+req.URL.Path[1:])
}

func Run_http_server() {
	http.HandleFunc("/", http_server)
	err := http.ListenAndServe("localhost:5000", nil)
	if err != nil {
		log.Fatal("ListenAndServe: ", err.Error())
	}
}
